public class Numbers
{
   /**
      Combines two numbers with a given operator.
      @param op one of "+", "-", "*", "/", or "^" (for power)
      @param first the first argument
      @param second the second argument
      @return the result of evaluating the operator with the arguments
   */
   public static double evaluate(String op, double first, double second)
   {
      double k=1;
      char ch = op.charAt(0);
      if(ch =='+')
      k = first+second;
      else if(ch =='-')
      k = first-second;
      else if(ch =='/')
      k = first/second;
      else if(ch =='*')
      k = first*second;
      else if(ch =='^'){
         for(int i=0;i<second;i++)
         k*=first;
      }
      return k;
   }
}